import request from './request'

// 审核管理API
export const auditAPI = {
  // 获取待审核项目（支持分页和搜索）
  getPendingItems(params) {
    return request({
      url: '/audits/pending',
      method: 'get',
      params
    })
  },

  // 获取审核历史（支持分页和搜索）
  getAuditHistory(params) {
    return request({
      url: '/audits/history',
      method: 'get',
      params
    })
  },

  // 审核项目（通过或拒绝）
  auditItem(data) {
    return request({
      url: '/audits/audit',
      method: 'post',
      data
    })
  },

  // 获取所有审核记录
  getAll() {
    return request({
      url: '/audits',
      method: 'get'
    })
  },

  // 获取待审核项目
  getPending() {
    return request({
      url: '/audits/pending',
      method: 'get'
    })
  },

  // 获取我的审核记录
  getMy() {
    return request({
      url: '/audits/my',
      method: 'get'
    })
  },

  // 根据ID获取审核记录
  getById(id) {
    return request({
      url: `/audits/${id}`,
      method: 'get'
    })
  },

  // 根据状态查询审核记录
  getByStatus(status) {
    return request({
      url: `/audits/status/${status}`,
      method: 'get'
    })
  },

  // 提交审核
  submit(data) {
    return request({
      url: '/audits/submit',
      method: 'post',
      data
    })
  },

  // 审核通过
  approve(achievementType, achievementId, comment) {
    return request({
      url: `/audits/approve?achievementType=${achievementType}&achievementId=${achievementId}&comment=${comment}`,
      method: 'post'
    })
  },

  // 审核拒绝
  reject(achievementType, achievementId, comment) {
    return request({
      url: `/audits/reject?achievementType=${achievementType}&achievementId=${achievementId}&comment=${comment}`,
      method: 'post'
    })
  },

  // 获取审核历史
  getHistory(achievementType, achievementId) {
    return request({
      url: `/audits/history?achievementType=${achievementType}&achievementId=${achievementId}`,
      method: 'get'
    })
  }
}
